//package com.fowo.api.exportmodel.service.impl;
//
//import com.fowo.api.exportmodel.service.RabbitMQService;
//import com.rabbitmq.client.AMQP;
//import com.rabbitmq.client.Channel;
//import org.springframework.amqp.rabbit.core.ChannelCallback;
//import org.springframework.amqp.rabbit.core.RabbitAdmin;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//
//@Component
//public class RabbitMQServiceImpl implements RabbitMQService {
//
//    @Resource
//    private RabbitAdmin rabbitAdmin;
//    @Override
//    public int getMessageCount(String queue) {
//
//        AMQP.Queue.DeclareOk declareOk = rabbitAdmin.getRabbitTemplate().execute(new ChannelCallback<AMQP.Queue.DeclareOk>() {
//            public AMQP.Queue.DeclareOk doInRabbit(Channel channel) throws Exception {
//                return channel.queueDeclarePassive(queue);
//            }
//        });
//        int messageCount = declareOk.getMessageCount();
//        return messageCount>=1 ? messageCount-1 : 0;
//    }
//}
